// pages/constmer/user-info/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    facePath: 'http://img4.imgtn.bdimg.com/it/u=2222268564,1498447840&fm=27&gp=0.jpg',
    sexArr: [
      {
        type: 0,
        value: '女'
      },
      {
        type: 1,
        value: '男'
      }
    ],
    userSex: '',
  },
  chooseFace: function () {
    var that = this;
    wx.chooseImage({
      count: 1,
      sizeType: ['original', 'compressed'],
      sourceType: ['album', 'camera'],
      success: function (res) {
        var tempFilePaths = res.tempFilePaths;
        // TODO 执行图片上传
        wx.saveFile({
          tempFilePath: tempFilePaths[0],
          success: function (res) {
            var savedFilePath = res.savedFilePath
            that.setData({
              facePath: savedFilePath
            });

          }
        })
      }
    });
  },
  userChangeSex: function (e) {
    var index = e.detail.value;
    var that = this;

    // TODO 执行远程提交

    that.setData({
      userSex: that.data.sexArr[index]
    });
  }
})
